use std::io;
use rand::Rng;

fn guessing() {
    println!("Guessing Game");
    
    let secret_num = rand::thread_rng().gen_range(1, 101);
    // println!("The random number was {}", secret_num);
    loop {
        println!("Please input your guess");

        let mut guess = String::new();
        io::stdin().read_line(&mut guess)
            .expect("Fail to read line");
        if guess.trim() == "quit" {
            println!("Bye");
            break;
        }
        let guess : u32 = guess.trim().parse()
            .expect("Input is not a number");
        // println!("You guessed: {}", guess);

        if guess > secret_num {
            println!("{} is too big", guess);
        }
        if guess < secret_num {
            println!("{} is too small", guess);
        }
        if guess == secret_num {
            println!("Gotcha! You win!");
            break;
        }
    }
    
}
